Support cargo:rustc-link-arg=FLAG
instruction in build script runner
#1061
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Cargo 1.50 added support for
cargo:rustc-link-arg
andcargo:rust-link-arg-bins
instructions in build script output (rustc-cdylib-link-arg
has been supported since 1.35 andcargo:rustc-link-arg-bin
was later added in 1.54).The build script runner currently prints a warning when
rustc-cdylib-link-arg
is used but entirely ignores the other ones (likely setting them asBuildScriptOutput::DepEnv
since this is the default branch).This patch adds support for the
cargo:rustc-link-arg
instruction and prints an warning whencargo:rust-link-arg-bins
andcargo:rust-link-arg-bin
are used, just likerustc-cdylib-link-arg
.Note that
cargo:rustc-link-arg
is important becausecargo
errors whencargo:rustc-flags
is used for anything that isn't a-l
or-L
flag (nb: this is enforced by cargo so it'd work with Bazel). There are cases (such as linking a-weak_framework
or-weak_library
on macos) that cannot usecargo:rustc-link-lib
and passing a custom-Clink-arg
is required)I think that we should also support
cargo:rust-link-arg-bins
,rustc-cdylib-link-arg
andcargo:rustc-link-arg-bin
but that's a bigger task since it requires knowing the crate type the build output will apply to. I've made issue #1062 for it.Ref: https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script